cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0042 NEW)

project (addon2)

if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"))
	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif()

include_directories(${CMAKE_JS_INC})

add_library(${PROJECT_NAME} SHARED src/addon.cpp)

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")

target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})

if (NODE_RUNTIME STREQUAL "node" AND NODE_RUNTIMEVERSION VERSION_GREATER_EQUAL 20)
	set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
elseif (NODE_RUNTIME STREQUAL "electron" AND NODE_RUNTIMEVERSION VERSION_GREATER_EQUAL 32)
	set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
elseif (NODE_RUNTIME STREQUAL "electron" AND NODE_RUNTIMEVERSION VERSION_GREATER_EQUAL 29)
	set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
endif()
